package com.zhdl.modules.demo.DCHTProcess;

//import com.zhdl.modules.common.entity.ConfigurationPLc;
//import com.zhdl.modules.common.test.GetPLCValue;
import com.zhdl.hardware_contact.hardware_config.entity.ProjectConfiguration;
import com.zhdl.modules.process.common.GetPLCValue;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class CameraInterface implements GetPLCValue {
    public static final String DEF_LOCATION = "0,0,0,0,0,0,0";
    public static final String DEF_BOOL = "0";
    public static final String CAMERA_RESULT1 = "触头拍照位1";
    public static final String CAMERA_RESULT2 = "拍照结果";
    public static final String DO_LUOSI_COMPLETE = "打螺丝机构完成";
    List<ProjectConfiguration> configurationPLcList;
    public void initData(){
        configurationPLcList = new ArrayList<>();
        configurationPLcList.add(new ProjectConfiguration("触头拍照位1",DEF_BOOL,1));
        configurationPLcList.add(new ProjectConfiguration("触头拍照位2",DEF_BOOL,1));
        configurationPLcList.add(new ProjectConfiguration("拍照结果",DEF_LOCATION,4));
        configurationPLcList.add(new ProjectConfiguration("打螺丝机构完成",DEF_BOOL,1));
    }
    @Override
    public ProjectConfiguration getValue(String field) {
        for (ProjectConfiguration configurationPLc : configurationPLcList) {
            if (configurationPLc.getValue().equals(field)){
                return configurationPLc;
            }
        }
        return null;
    }
    public void upDataValue(String field,String value){
        for (ProjectConfiguration configurationPLc : configurationPLcList) {
            if (configurationPLc.getValue().equals(field)){
                configurationPLc.setValue(value);
            }
        }
    }
}
